<?php
	class Foods extends CI_Model {		
		function __construct() {
			parent::__construct();
			$this->load->database();
		}
		
		//
		function getFoods() {
			$result = $this->db->query("select * from food");
			
			return $result->result();
		}
		
		function toJson() {
			$foods = $this->getFoods();
			
			foreach($foods as $item) {
				$item->des = urlencode($item->des);
			}
			
			$strJson = json_encode($foods);
			return urldecode($strJson);
		}
	}
?>